<template>
    <div class="register-wrap">
        <div class="ms-login">
            <div class="ms-title">注册</div>
            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="0px" class="ms-content">
                 <el-form-item>
                        <el-select class="user-select" v-model="userSceal" placeholder="请选择身份">
                            <el-option key="xtc" checked label="商家" value="seller"></el-option>
                            <el-option key="imoo" label="普通用户" value="commonuser"></el-option>
                        </el-select>
                    </el-form-item>
                <div v-if="userSceal == 'commonuser'">
                <el-form-item prop="username">
                    <el-input v-model="ruleForm.username" placeholder="姓名">
                        <el-button slot="prepend" icon="el-icon-lx-people"></el-button>
                    </el-input>
                </el-form-item>
                <el-form-item prop="password">
                    <el-input type="password" placeholder="密码" v-model="ruleForm.password" @keyup.enter.native="submitForm('ruleForm')">
                        <el-button slot="prepend" icon="el-icon-lx-lock"></el-button>
                    </el-input>
                </el-form-item>
                <el-form-item prop="confirmPassword">
                    <el-input type="password" placeholder="确认密码" v-model="ruleForm.confirmPassword" @keyup.enter.native="submitForm('ruleForm')">
                        <el-button slot="prepend" icon="el-icon-lx-lock"></el-button>
                    </el-input>
                </el-form-item>
                <el-form-item prop="confirmPassword">
                    <el-input type="password" placeholder="出生日期" v-model="ruleForm.confirmPassword" @keyup.enter.native="submitForm('ruleForm')">
                        <el-button slot="prepend" icon="el-icon-lx-lock"></el-button>
                    </el-input>
                </el-form-item>
                <el-form-item prop="confirmPassword">
                    <el-input type="password" placeholder="手机号码" v-model="ruleForm.confirmPassword" @keyup.enter.native="submitForm('ruleForm')">
                        <el-button slot="prepend" icon="el-icon-lx-lock"></el-button>
                    </el-input>
                </el-form-item>
                <el-form-item prop="confirmPassword">
                    <el-input type="password" placeholder="电子邮箱" v-model="ruleForm.confirmPassword" @keyup.enter.native="submitForm('ruleForm')">
                        <el-button slot="prepend" icon="el-icon-lx-lock"></el-button>
                    </el-input>
                </el-form-item>
                <el-form-item prop="confirmPassword">
                    <el-input type="password" placeholder="地址" v-model="ruleForm.confirmPassword" @keyup.enter.native="submitForm('ruleForm')">
                        <el-button slot="prepend" icon="el-icon-lx-lock"></el-button>
                    </el-input>
                </el-form-item>
                </div>
                <div v-if="userSceal == 'seller'">
                  <el-form-item prop="username">
                    <el-input v-model="ruleForm.username" placeholder="商户名">
                        <el-button slot="prepend" icon="el-icon-lx-people"></el-button>
                    </el-input>
                </el-form-item>
                <el-form-item prop="password">
                    <el-input type="password" placeholder="密码" v-model="ruleForm.password" @keyup.enter.native="submitForm('ruleForm')">
                        <el-button slot="prepend" icon="el-icon-lx-lock"></el-button>
                    </el-input>
                </el-form-item>
                <el-form-item prop="confirmPassword">
                    <el-input type="password" placeholder="确认密码" v-model="ruleForm.confirmPassword" @keyup.enter.native="submitForm('ruleForm')">
                        <el-button slot="prepend" icon="el-icon-lx-lock"></el-button>
                    </el-input>
                </el-form-item>
                <el-form-item prop="confirmPassword">
                    <el-input type="password" placeholder="联系电话" v-model="ruleForm.confirmPassword" @keyup.enter.native="submitForm('ruleForm')">
                        <el-button slot="prepend" icon="el-icon-lx-lock"></el-button>
                    </el-input>
                </el-form-item>
                <el-form-item prop="confirmPassword">
                    <el-input type="password" placeholder="商家地址" v-model="ruleForm.confirmPassword" @keyup.enter.native="submitForm('ruleForm')">
                        <el-button slot="prepend" icon="el-icon-lx-lock"></el-button>
                    </el-input>
                </el-form-item>
                <el-form-item prop="confirmPassword">
                    <el-input type="password" placeholder="法人姓名" v-model="ruleForm.confirmPassword" @keyup.enter.native="submitForm('ruleForm')">
                        <el-button slot="prepend" icon="el-icon-lx-lock"></el-button>
                    </el-input>
                </el-form-item>
                <el-form-item prop="confirmPassword">
                    <el-input type="password" placeholder="商家简介" v-model="ruleForm.confirmPassword" @keyup.enter.native="submitForm('ruleForm')">
                        <el-button slot="prepend" icon="el-icon-lx-lock"></el-button>
                    </el-input>
                </el-form-item>
                <el-form-item prop="confirmPassword">
                    <el-input type="password" placeholder="上传营业执照" v-model="ruleForm.confirmPassword" @keyup.enter.native="submitForm('ruleForm')">
                        <el-button slot="prepend" icon="el-icon-lx-lock"></el-button>
                    </el-input>
                </el-form-item>
                </div>
                <div class="login-btn">
                    <el-button type="primary" @click="submitForm('ruleForm')">确认</el-button>
                </div>
                <!-- <p class="login-tips">Tips : 用户名和密码随便填。</p> -->
            </el-form>
        </div>
    </div>
</template>

<script>
    export default {
        data: function(){
            return {
                ruleForm: {
                    username: '',
                    password: '',
                    confirmPassword: ''
                },
                rules: {
                    username: [
                        { required: true, message: '请输入用户名', trigger: 'blur' }
                    ],
                    password: [
                        { required: true, message: '请输入密码', trigger: 'blur' }
                    ],
                    confirmPassword: [
                        { required: true, message: '请确认密码', trigger: 'blur' }
                    ],
                },
                userSceal:''
            }
        },
        methods: {
            submitForm(formName) {
                if(!this.userSceal){
                 this.$message.error('请选择身份');
                    return
                }
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        console.log(this.userSceal)
                        localStorage.setItem('ms_username',this.ruleForm.username);
                            this.$router.push('/login')
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            }
        }
    }
</script>

<style scoped>
    .register-wrap{
        position: relative;
        width:100%;
        height:100%;
        background-image: url(../../assets/img/login-bg.jpg);
        background-size: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .ms-title{
        width:100%;
        line-height: 50px;
        text-align: center;
        font-size:20px;
        color: #fff;
        border-bottom: 1px solid #ddd;
    }
    .ms-login{
        
        width:350px;
        border-radius: 5px;
        background: rgba(255,255,255, 0.3);
        overflow: hidden;
    }
    .ms-content{
        padding: 30px 30px;
    }
    .login-btn{
        text-align: center;
    }
    .login-btn button{
        width:100%;
        height:36px;
        margin-bottom: 10px;
    }
    .login-tips{
        font-size:12px;
        line-height:30px;
        color:#fff;
    }
    .user-select{
        width: 100%;
    }
</style>